﻿@model MVC4Shop.Models.ProductModel

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
<script type="text/javascript">
    var i = 1;
    var s; 
    function preview() {
        var col = $("#color").val();
        var textcol = $("#color option[value='" + col + "']").text();
        var size = $("#size").val();
        $('#tb').append('<tr><td>' + col + '</td><td>' + size + '</td></tr>');
        //document.getElementById('detailst').innerHTML = x;
        i++;
        var text = $('#txthidden').val();
        $('#txthidden').val(text + '+' + size + ',' + col);
        alert(textcol);
    }

</script>
@using (Html.BeginForm("Create", "Product", FormMethod.Post, new { enctype = "multipart/form-data" })) {
    @Html.ValidationSummary(false)

    <fieldset>
        <legend>ProductModel</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.name)
            @Html.ValidationMessageFor(model => model.name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.image)
        </div>
        <div class="editor-field">
              <input type="file" name="file" />   

        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.price)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.price)
            @Html.ValidationMessageFor(model => model.price)
        </div>

      


        <div class="editor-label">
            @Html.LabelFor(model => model.catategory_name)
        </div>
        <div class="editor-field">
         @Html.DropDownListFor(model => model.category_id, new SelectList(MVC4Shop.dao.CategoryDAO.GetAll() as System.Collections.IEnumerable, "id", "name"))
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.color)
        </div>
        <div class="editor-field">
          @Html.DropDownListFor(model => model.color, new SelectList(MVC4Shop.dao.ColorDAO.GetAll() as System.Collections.IEnumerable, "id", "name"))
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.size)
        </div>
        <div class="editor-field">
             @Html.DropDownListFor(model => model.size, new SelectList(MVC4Shop.dao.SizeDAO.GetAll() as System.Collections.IEnumerable, "id", "name"))
        </div>

          <div class="editor-label">
            @Html.LabelFor(model => model.details)
        </div>
        <div class="editor-field">
    
            @Html.TextAreaFor(model => model.details, new { @id = "elm1" })
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.details, new { @id ="detailst"})
        </div>

        <p>
            <input type="submit" value="Create" /> <input type="button" value="preview" onclick="preview()" />
        </p>

        <table id="tb">
            
        </table>

         <input type="hidden" id="txthidden"/>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
